package de.cube3d.blitwit.test.cases 
{
	import de.cube3d.blitwit.render.BlitSpriteScene;
	import de.cube3d.blitwit.test.Test;
	import de.cube3d.blitwit.test.Util;
	import flash.geom.Point;
	import flash.display.Graphics;
	import flash.utils.getTimer;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.display.BitmapData;
	import de.cube3d.blitwit.render.*;
	import de.cube3d.blitwit.space.*;

	
	/**
	 * Make a scene with one million randomly generated sprites. Takes a while to start up
	 * but it stress tests the whole thing nicely. 
	 */
	public class Test1M extends Test
	{
		
		override protected function init():void {
			var bgspace:GridSpace = new GridSpace( -50000, -50000, 100000, 100000,200,200);
			var fgspace:BTSpace = new BTSpace ( -50000, -50000, 100000, 100000);
			bgspace.add(new BlitSpriteTexture(Util.getBitmap("tile_ground_grass"), -50000, -50000, 100000, 100000).setSortIndex(-100000));
			var sprites:Vector.<BitmapData> = new Vector.<BitmapData>();
			for (var i:int = 0; i < 10; i += 1) sprites.push(Util.getBitmap("fountain_" + i));
			
			var spread:int = 80000;
			var xoff:int = 300;
			var yoff:int = 200;
			
			for (i = 0; i < 1000000; i += 1) {
				var y:Number = (Util.random() - .5) * spread + yoff;
				if (Util.random() > .6) {
					if (Util.random()>.2) {
						fgspace.add(new BlitSpriteBitmap(Util.getBitmap("house_1_" + (i % 4 + 1)), (Util.random() - .5) * spread+xoff, y).setSortIndex(y))
					} else {
						fgspace.add(new AnimatedBitmap(sprites, (Util.random() - .5) * spread+xoff, y, 15 + Util.random()*10).setSortIndex(y))
					}
				} else {
					var bms:String = _base[int(Util.random() * _base.length)] as String;
					bgspace.add(new BlitSpriteBitmap(Util.getBitmap(bms), (Util.random() - .5) * spread+xoff, y).setSortIndex(y - 1000))	
				}
				
			}
			
			scene.append(bgspace);
			scene.append(fgspace);
			
		}
		
	}

}